<!--
 * @Author: ChunLai
 * @Date: 2023-03-17 14:14:44
 * @LastEditTime: 2025-09-02 18:22:07
 * @Description: pdf非必读文档
 * @FilePath: \02.bldinsure\src\views\sign\components\protocols\PdfList.vue
-->
<template>
  <div class="protocol">
    <div class="notice_img" @click="readClick">
      <MsImgIcon size="13" name="checked" v-if="pdfFinish" />
    </div>
    <div class="clause_ul">
      <i>本人充分阅读、理解并同意</i>
      <em
        v-for="(item, index) in lists"
        :key="`pdflists-${index}`"
        @click.stop="openPdf(item)"
      >
        {{ getFileName(item, index) }}
      </em>
    </div>
    <PdfReader
      ref="mustNotReadRef"
      btype="pop"
      clickMode="0"
      btnText="我已阅读并知悉"
      @toClick="showFile = false"
      v-if="showFile"
    />
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import PdfReader from "@/components/PdfReader";
export default {
  name: "PdfList",
  data() {
    return {
      showFile: false,
    };
  },
  components: { PdfReader },
  computed: {
    ...mapGetters({
      lists: "readings/pdfLists",
      pdfFinish: "readings/pdfFinish",
    }),
  },
  created() {},
  mounted() {},
  watch: {},
  methods: {
    getFileName(item, index) {
      let res = "",
        symbol = "",
        name = `${item.fileName || ""}`;
      if (index != this.lists.length - 1) {
        symbol = "、";
      }
      if (name && name.indexOf("《") == -1) {
        name = `《${name}》`;
      }
      res = `${name}${symbol}`;
      return res;
    },
    readClick() {
      this.$store.dispatch("readings/setItemFinish", {
        type: "pdf",
      });
    },
    openPdf(item) {
      if (!item.fileUrl) return this.$toast("未查询到该文件");
      this.showFile = true;
      this.$nextTick(() => {
        this.$refs.mustNotReadRef.initModule(item.fileUrl, item.fileName);
      });
    },
  },
};
</script>

<style lang="less" scoped>
@import "./style.less";
</style>
